package net.zjitc.servlet.cart;

import net.zjitc.domain.Book;
import net.zjitc.service.BookService;
import net.zjitc.service.impl.BookServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

/**
 * Created by rj1502 on 2017/10/16.
 */
@WebServlet(name = "BookListServlet" ,urlPatterns = "/listServlet")
public class BookListServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        BookService bookService = new BookServiceImpl();
        List<Book> list = null;
        try {
            list = bookService.findAll();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        request.setAttribute("list",list);
        request.getRequestDispatcher("/cart/booklist.jsp").forward(request,response);
    }
}
